//
//  FQDSystemMessageViewController.m
//  FakeQDaily
//
//  Created by mewxiv on 9/28/16.
//  Copyright © 2016 Xensius. All rights reserved.
//

#import "FQDSystemMessageViewController.h"
#import "FQDQIconEmptyCell.h"
#import "FQDSimpleFeedCellItemProvider.h"
#import "FQDMyCommentMessageCellItem.h"
#import "FQDRestModel.h"
#import "QDailyAPI.h"

@interface FQDSystemMessageViewController ()

@end

@implementation FQDSystemMessageViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self setupCellItemProvider];
    [self loadNewCellItemsWithCompletion:nil];
}

- (void)setupCellItemProvider
{
    FQDSimpleFeedCellItemProvider *provider = [[FQDSimpleFeedCellItemProvider alloc] init];
    provider.responseFeedsName = @"comments";
    provider.responseFeedClass = [FQDMyCommentMessage class];
    provider.cellItemClass = [FQDMyCommentMessageCellItem class];
    [provider setFetchFeedBlock:^(NSString *feedId, NSString *cursorKey, QDailyAPICompleteBlock completion) {
        [[QDailyAPI sharedAPI] getMyPraiseMessages:cursorKey completion:completion];
    }];
    self.provider = provider;
}

#pragma mark - FQDFeedBaseViewController DataSource
- (NSArray *)cellClasses
{
    return @[
        [FQDQIconEmptyCell class],
    ];
}


- (NSInteger)numberOfHeaderCellsInCollectionView:(UICollectionView *)collectionView
{
    BOOL hasFeeds = [self.provider.cellItems count] > 0;
    BOOL hasMoreCellItems = [self.provider hasMoreCellItems];
    BOOL shouldShowEmptyCell = (!hasFeeds && !hasMoreCellItems);
    NSInteger headerCount = (shouldShowEmptyCell) ? 1 : 0;
    return headerCount;
}

- (Class)headerCellClassAtIndexPath:(NSIndexPath *)indexPath inCollectionView:(UICollectionView *)collectionView
{
    if (indexPath.section == 0) {
        return [FQDQIconEmptyCell class];
    }
    return nil;
}

- (Class)cellClassForCellItem:(FQDFeedCellItem *)cellItem
{
    return nil;
}

#pragma mark - FQDFeedBaseViewController Deleagte
- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForHeaderCellAtIndexPath:(NSIndexPath *)indexPath
{
    CGSize cvSize = collectionView.frame.size;
    return cvSize;
}

- (void)configureHeaderCell:(UICollectionViewCell *)headerCell atIndexPath:(NSIndexPath *)indexPath inCollectionView:(UICollectionView *)collectionView
{
    if (indexPath.section == 0) {
        FQDQIconEmptyCell *emptyCell = (FQDQIconEmptyCell *)headerCell;
        emptyCell.titleText = @"我收到的好奇心消息会出现在这里";
    }
}

@end
